from datetime import datetime
now = datetime.now()
date_time = now.strftime("%Y-%m-%d, %H:%M:%S")
print(date_time)
# cogs/Times.py
# 略
@commands.command(pass_context = True)@bot.command()
async def time(ctx):
now = datetime.now()
await ctx.send(now.strftime("%Y-%m-%d %H:%M:%S"))
# 略
# cogs/randomLucky.py
# 略
import random
lucky = ["lucky~~~", "not bad", "Soso", "green hat",
"fuck your self"]
class randomLucky(Cog_Extension):
@commands.command(pass_context = True)
async def rand(ctx):
cat = random.randint(0, 4)
await ctx.channel.send(lucky[int(cat)])
# 略
如果我只想要一人一天只能發送一次呢??
我們要怎麼做?
剛才使用的author可以來出來了~~
建立名為match的json檔
{
}
# 寫在最下面
async def read_data():
with open("match.json", "r") as file:
users = json.load(file)
return users
# bot.run...
這個函式可以讀取json檔(唯讀),所以我將他每個users的這個key回傳
然後,要怎麼寫??